package com.garvin.dto.base;

import com.garvin.enums.HttpResponseCodeEnum;
import lombok.Data;

/**
 * @author : garvin
 * @version V1.0
 * @date : 2020年07月06日 16:13
 */
@Data
public class BaseResponseDto<T> {
    private Integer code;
    private String message;
    private T data;

    public BaseResponseDto<T> success() {
        code = HttpResponseCodeEnum.SUCCESS.getCode();
        message = HttpResponseCodeEnum.SUCCESS.getMessage();
        return this;
    }

    public BaseResponseDto<T> fail() {
        code = HttpResponseCodeEnum.FAIL.getCode();
        message = HttpResponseCodeEnum.FAIL.getMessage();
        return this;
    }

    public BaseResponseDto<T> set(HttpResponseCodeEnum response) {
        code = response.getCode();
        message = response.getMessage();
        return this;
    }
}
